package com.ice.test.user;

import com.zeroc.Ice.Communicator;
import com.zeroc.Ice.Identity;
import com.zeroc.Ice.ObjectAdapter;
import com.zeroc.Ice.Util;
import java.util.logging.Logger;

public class Server {
    private static Logger logger = Logger.getLogger(Server.class.getSimpleName());

    public static void main(String[] args) {
        //一样的步骤，初始化通信器
        Communicator communicator = Util.initialize(args);

        //创建ice适配器，主要用于将服务调用地址和服务名映射起来
        //"HelloServiceAdapter"是适配器名，"default -h -p"是服务器调用地址、端口号
        ObjectAdapter adapter =
                communicator.createObjectAdapterWithEndpoints("HelloServiceAdapter","default -h 192.168.10.1 -p 1888");
        //将服务的具体实现类servant提交给适配器
        Object servant=new HelloI();
        //"HelloIce"--服务接口在ice中注册名,转成唯一标识identity
        Identity id = Util.stringToIdentity("HelloIce");
        adapter.add((com.zeroc.Ice.Object)servant,id);

        //激活适配器
        adapter.activate();

        logger.info("server服务器已经启动。。。");


    }
}
